@import "mixins/all";
@import "compass/css3/background-size";

/* Height of the whole header bar */
$headerHeight: lines(2.5);

/* Height of an element (i.e. button) in the header bar */
$elementHeight: em(40);

/* Element padding, i.e. empty space on the top and below of the element */
$elementPadding: ($headerHeight - $elementHeight) / 2;

/* Line heights, add -3px finetuning, text looks better */
$buttonLineHeight: $elementHeight - em(3);
$textLineHeight: $headerHeight - em(3);

/* Default spacing between header bar elements */
$elementSpacing: lines(0.5);

.header {
  height: $headerHeight;
  width: 100%;
}

.header-wrapper {
  @include wrapper(0);
}

.header-left {
  float: left;
}

.header-right {
  float: right;
}

/* Buttons may need padding, text links don't */
.header-padding {
  margin-left: $elementSpacing;
}

/* Vertically centered block element in header bar */
@mixin header-block {
  display: block;
  margin-top: $elementPadding;
  margin-bottom: $elementPadding;
  height: $elementHeight;
}

.header-hover {
  &:hover {
    background-color: $highlight;
  }

  &.toggled {
    background-color: $light-body;
  }
}

.header-logo {
  display: block;
  @include header-block;
}

.header-text-link {
  height: $headerHeight;
  line-height: $textLineHeight;
  padding-right: $elementSpacing;
  padding-left: $elementSpacing;
  display: block;
  color: $body;

  &:hover {
    color: $body;
  }

  .toggled & {
    color: $background;
  }
}

@mixin header-menu-button($bgcolor) {
  @include button($bgcolor);
  @include header-block;
  padding-left: em(20);
  padding-right: em(20);
  line-height: $buttonLineHeight;
}

.new-listing-link {
  @include header-menu-button($link2);
  max-width: em(200);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-menu-container {
  display: block;
  padding: $elementPadding $elementSpacing;
  height: $headerHeight;
}

.header-menu-toggle-container {
  @include button($highlight);
  @include button-group-button-padding;
  height: $elementHeight;
  line-height: $buttonLineHeight;
  margin: 0;
  padding-bottom: 0;
  padding-top: 0;
  color: $body;

  .toggled & {
    color: $background;
    background-color: $light-body;
  }
}

.header-menu-icon {
  @include icon-fix-more;

  @include media(tablet) {
    padding-right: em(4);
  }
}

.header-user-avatar {
  @include border-radius($default-border-radius);
  @include header-block;
}

.header-user-toggle {
  padding-left: $elementSpacing;
  display: block;
  @include clearfix;
}

@mixin header-toggle-menu {
  min-width: em(200);
  position: absolute;
}

.header-toggle-menu-language {
  @include header-toggle-menu;
}

.header-toggle-menu-user {
  @include header-toggle-menu;
}

.header-toggle-menu-menu {
  @include header-toggle-menu;
}

.header-inbox-link {
  color: $body;

  position: relative;
}

.header-inbox {
  @include big-type;

  // Icon fix
  position: relative;
  top: em(4);
}

.badge {
  position: absolute;
  top: em(30); // Magic, just looks good
  left: em(23); // Magic, just looks good
  background: $link;
  color: $background;
  @include badge(20px);

  &.big-badge {
    @include badge(26px);
    top: em(28); // Magic, just looks good
    left: em(18); // Magic, just looks good
  }

  &.huge-badge {
    @include badge(32px);
    top: em(27); // Magic, just looks good
    left: em(13); // Magic, just looks good
  }
}

.mobile-badge {
  display: inline-block;
  color: $light-body;
  background-color: $background;
  @include badge(20px);
  margin-left: lines(0.5);
}

.header-wide-logo-text,
.header-square-logo-text {
  margin-top: 0.625rem;
  margin-bottom: 0.625rem;
  line-height: 2.5rem;
  height: 2.5rem;
  font-size: em(28);
  letter-spacing: -0.03em;
  text-transform: uppercase;
  font-weight: 800;
}

.header-wide-logo-text {
  @include ellipsis;
  width: rem(150);
  height: rem(40);
}

.header-square-logo-text {
  width: rem(40);
  height: rem(40);
}

.header-wide-logo {
  background-image: url(image-path($wide-logo-lowres-url));

  @include highres {
    background-image: url(image-path($wide-logo-highres-url));
  }

  width: em(168);
  height: em(40);

  // Highres image
  background-repeat: no-repeat;
  @include background-size(em(168) auto);

  display: inline-block;
}

.header-square-logo {
  background-image: url(image-path($square-logo-lowres-url));

  @include highres {
    background-image: url(image-path($square-logo-highres-url));
  }

  width: em(40);
  height: em(40);

  // Highres image
  background-repeat: no-repeat;
  @include background-size(em(40) auto);

  display: inline-block;
}
